/**
  \file dawg_rbt.h
  \author Francis Girard
  \date 26 october 2013

  Red black tree extension to fullfil dawg needs.
*/

/*
 *  Copyright (C) 2013, Francis Girard
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __dawg_red_black_tree_h__
#define __dawg_red_black_tree_h__

#include "dawg_arr_void_ptr.h"

typedef void* DAWG_RBT_EL_TYPE;
#define DAWG_RBT_COMP_LT(a,b) (a < b)
#define DAWG_RBT_COMP_EQ(a,b) (a == b)

typedef void* h_dawg_rbt;

typedef enum
{
  DAWG_RBT_STATUS_OK,
  DAWG_RBT_STATUS_MEM_EXHAUSTED,
  DAWG_RBT_STATUS_DUPLICATE_KEY,
  DAWG_RBT_STATUS_KEY_NOT_FOUND
} dawg_rbt_status_enum;

h_dawg_rbt dawg_rbt_create();
void dawg_rbt_destroy(h_dawg_rbt hRBT);
dawg_rbt_status_enum dawg_rbt_insert(h_dawg_rbt hRBT, DAWG_RBT_EL_TYPE oEl);
dawg_rbt_status_enum dawg_rbt_find(h_dawg_rbt hRBT, DAWG_RBT_EL_TYPE oEl);
dawg_rbt_status_enum dawg_rbt_remove(h_dawg_rbt hRBT, DAWG_RBT_EL_TYPE oEl);
void dawg_rbt_linearize(h_dawg_rbt hRBT, h_dawg_arr_void_ptr hArr);

// #ifndef __dawg_red_black_tree_h__
#endif
